package com.gitee.wsl.mathematics.algebraic

import com.gitee.wsl.mathematics.algebraic.number.ScaleOperations
import com.gitee.wsl.mathematics.algebraic.op.ExponentialOperations
import com.gitee.wsl.mathematics.algebraic.op.PowerOperations
import com.gitee.wsl.mathematics.algebraic.op.TrigonometricOperations

/**
 * Advanced Number-like semifield that implements basic operations.
 */
interface ExtendedFieldOps<T> :
    FieldOps<T>,
    TrigonometricOperations<T>,
    ExponentialOperations<T>,
    ScaleOperations<T>,
    PowerOperations<T> {

    override fun tan(arg: T): T = sin(arg) / cos(arg)
    override fun tanh(arg: T): T = sinh(arg) / cosh(arg)

    override fun unaryOperationFunction(operation: String): (arg: T) -> T = when (operation) {
        TrigonometricOperations.COS_OPERATION -> ::cos
        TrigonometricOperations.SIN_OPERATION -> ::sin
        TrigonometricOperations.TAN_OPERATION -> ::tan
        TrigonometricOperations.ACOS_OPERATION -> ::acos
        TrigonometricOperations.ASIN_OPERATION -> ::asin
        TrigonometricOperations.ATAN_OPERATION -> ::atan
        ExponentialOperations.EXP_OPERATION -> ::exp
        ExponentialOperations.LN_OPERATION -> ::ln
        ExponentialOperations.COSH_OPERATION -> ::cosh
        ExponentialOperations.SINH_OPERATION -> ::sinh
        ExponentialOperations.TANH_OPERATION -> ::tanh
        ExponentialOperations.ACOSH_OPERATION -> ::acosh
        ExponentialOperations.ASINH_OPERATION -> ::asinh
        ExponentialOperations.ATANH_OPERATION -> ::atanh
        else -> super<FieldOps>.unaryOperationFunction(operation)
    }
}